<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 开发环境版本，包含了有帮助的命令行警告 -->
		<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	</head>
	<body>
		<div id="app">
		    <button @click="counter++">+</button> {{counter}}
			<button @click="counter--">-</button>
			
			<hr>
			<input type="text"  v-model="kilometers" />千米<br>
			<input type="text" v-model="meters">米
		</div>
	</body>
	
	<script>
		
		var vue = new Vue({
			el:"#app",
			data:{
				counter:0,
				kilometers:0, //千米
				meters:0 //米
			},
			watch:{
				counter:function(newValue,oldValue)
				{
					alert("new:"+newValue + " old:"+oldValue);
				},
				kilometers:function(newValue,oldValue){
					this.meters = newValue*1000;
				},
				meters:function(newValue,oldValue){
					this.kilometers = newValue/1000;
				}
				
			}
		});
		
	</script>
</html>





